package cn.sdhuijin.healthexam.activity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import cn.sdhuijin.healthexam.ExitApplication;
import cn.sdhuijin.healthexam.R;
import cn.sdhuijin.healthexam.control.AbstractControlActivity;
import cn.sdhuijin.healthexam.util.Constants;

/**
 * 健康体检录入-第一页
 * 
 * @author houyuchun
 * 
 */
public class HealthExamFirstActivity extends AbstractControlActivity implements
		OnClickListener {
	private String createDate;
	// 症状
	private int[] checkZhengzIds = { R.id.check_zhengz_wu,
			R.id.check_zhengz_toutong, R.id.check_zhengz_touyun,
			R.id.check_zhengz_xinji, R.id.check_zhengz_xiongmen,
			R.id.check_zhengz_xiongtong, R.id.check_zhengz_kesou,
			R.id.check_zhengz_ketan, R.id.check_zhengz_huxikunnan,
			R.id.check_zhengz_duoyin, R.id.check_zhengz_duoniao,
			R.id.check_zhengz_tizhongxiajiang, R.id.check_zhengz_fali,
			R.id.check_zhengz_guanjiezhongtong, R.id.check_zhengz_shilimohu,
			R.id.check_zhengz_shoujiaomamu, R.id.check_zhengz_niaoji,
			R.id.check_zhengz_niaotong, R.id.check_zhengz_bianmi,
			R.id.check_zhengz_fuxie, R.id.check_zhengz_outu,
			R.id.check_zhengz_yanhua, R.id.check_zhengz_erming,
			R.id.check_zhengz_rufangzhangtong };

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_health_exam_first);
		ExitApplication.getInstance().addActivity(this);

		Intent intent = getIntent();
		Bundle bundle = intent.getBundleExtra("bundle");
		if (bundle != null) {
			createDate = bundle.getString("createDate");
		}
		setCurrentEditUserName(createDate);

		addEditTextView(R.id.edt_user_name, "姓名");
		addEditTextView(R.id.edt_identify_num, "身份证号");
		addEditTextView(R.id.edt_exam_date, "体检日期");
		addEditTextView(R.id.edt_duty_doctor, "责任医生");
		addCheckBoxGroupView(checkZhengzIds, "症状", R.id.edt_zhengz_qita,
				"症状-其他", "无症状");
		addEditTextView(R.id.edt_tiwen, "体温");
		addEditTextView(R.id.edt_mailv, "脉率");
		addEditTextView(R.id.edt_huxipinlv, "呼吸频率");
		addEditTextView(R.id.edt_zuocegaoya, "左侧高压");
		addEditTextView(R.id.edt_zuocediya, "左侧低压");
		addEditTextView(R.id.edt_youcegaoya, "右侧高压");
		addEditTextView(R.id.edt_youcediya, "右侧低压");
		addEditTextView(R.id.edt_shengao, "身高");
		addEditTextView(R.id.edt_tizhong, "体重");
		addEditTextView(R.id.edt_yaowei, "腰围");
		addEditTextView(R.id.edt_tizhizhishu, "体质指数");
		// Properties文件路径
		controlManager.setPropertiesPath(Constants.PROPERTIES_PATH + createDate
				+ ".txt");
		Log.i(HealthExamFirstActivity.class.getSimpleName(), "文件路径： "
				+ Constants.PROPERTIES_PATH + createDate + ".txt");
		controlManager.toControl();

		setEditTextListener(R.id.edt_exam_date);
		this.setButtonListener(this, R.id.btn_next, R.id.btn_back);
	}

	/**
	 * 按钮点击处理事件
	 */
	@Override
	public void onClick(View arg0) {
		Intent intent = new Intent();
		Bundle bundle = new Bundle();
		// 获取点击按钮ID
		int id = (Integer) arg0.getId();
		switch (id) {
		case R.id.btn_next:
			controlManager.toProperties();
			intent.setClass(this, HealthExamSecondActivity.class);
			bundle.putString("createDate", createDate);
			intent.putExtra("bundle", bundle);
			startActivity(intent);
			this.finish();
			break;
		case R.id.btn_back:
			this.finish();
			break;
		default:
			break;
		}
	}
}
